<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="姓名" v-model="emp.name">
    <input type="text" placeholder="工资" v-model="emp.salary">
    <input type="text" placeholder="岗位" v-model="emp.job">
    <input type="button" value="添加员工" @click="f()">
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>工资</th>
            <th>岗位</th>
            <th>操作</th>
        </tr>
        <!--i表示的是当前遍历数组中对象的下标-->
        <tr v-for="(e,i) in arr">
            <td>{{i+1}}</td>
            <td>{{e.name}}</td>
            <td>{{e.salary}}</td>
            <td>{{e.job}}</td>
            <td><input type="button" value="删除" @click="del(i)"></td>
        </tr>
    </table>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            arr: [],
            emp: {name: "", salary: "", job: ""},

        },
        methods: {
            f() {
                v.arr.push({name: v.emp.name, salary: v.emp.salary, job: v.emp.job});
            },
            del(i) {
                /*从数组中删除对象 splice(删除的位置,删除的数量)*/
                v.arr.splice(i, 1);
            },
        }
    })
</script>

</body>
</html>